﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessFacade;
using System.Configuration;
using System.IO;
using Comm;

namespace MedicareNoteManagerWeb.Web
{
    public partial class backups : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string path = ConfigurationManager.ConnectionStrings["routes"].ToString();
            if (!IsPostBack)
            {
                if (Directory.Exists(path))//判断是否存在        
                {

                }
                else
                {
                    Directory.CreateDirectory(path);//创建新路径       
                }
            }
        }

        protected void btnchongzhi_Click(object sender, EventArgs e) //清空textbox中的内容
        {
            this.TextBox1.Text = "";
            this.TextBox2.Text = "";
        }

        protected void btnOk_Click(object sender, EventArgs e)//设置备份时间
        {
            try
            {
                if (string.IsNullOrEmpty(this.TextBox1.Text))  //备份时间不超过一天的时间设置
                {
                    int time2 = int.Parse(this.TextBox2.Text.Trim());
                    int time = time2;
                    Busi_sys_backups update = new Busi_sys_backups();
                    update.updatetime(time);
                    MessageBox.ShowDialog(this.Page, "设置成功", "success");
                }
                else                                           //备份时间超过一天的时间设置
                {
                    int time1 = int.Parse(this.TextBox1.Text.Trim());
                    int time2 = int.Parse(this.TextBox2.Text.Trim());
                    int time = time1 * 24 + time2;
                    Busi_sys_backups update = new Busi_sys_backups();
                    update.updatetime(time);
                    MessageBox.ShowDialog(this.Page, "设置成功", "success");
                }
            }
            catch { MessageBox.ShowDialog(this.Page, "设置失败", "success"); }
            }
    }
}
